package cn.myschool.test.day3;

import cn.myschool.dao.ExamDao;
import cn.myschool.entity.ExamResult;
import cn.myschool.util.MybatisUtil;
import org.apache.ibatis.session.SqlSession;

import java.util.Date;
import java.util.List;

/**
 * @author oldliu
 * @since 1.0
 */
public class Level2Cache {
    public static void main(String[] args) {
//        f1();
//        System.out.println(">>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>");
//        //f2();
//        System.out.println(">>>>>>>>>>>>>>>>>>>>add new:");
       addNew();
//        System.out.println(">>>>>>>>>>>>>>>>>>>>after add new:");
//        f1();
    }
    static void f1(){
        SqlSession s= MybatisUtil.get();
        ExamDao dao=s.getMapper(ExamDao.class);
        List<ExamResult> list1 = dao.findALL();
        list1.forEach(System.out::println);

        MybatisUtil.close(s);
    }
    static void f2(){
        SqlSession s= MybatisUtil.get();
        ExamDao dao=s.getMapper(ExamDao.class);
        List<ExamResult> list1 = dao.findALL();
        list1.forEach(System.out::println);
        MybatisUtil.close(s);
    }
    static void addNew(){
        SqlSession s= MybatisUtil.get();
        ExamDao dao=s.getMapper(ExamDao.class);
        ExamResult r=new ExamResult();
        r.setScore(89.5F);
        r.setExamDate(new Date());
        r.setStid(251L);
        r.setSbid(48L);
        dao.add(r);
        MybatisUtil.close(s);
    }
}
